package cn.wolfcode.luowowo.article.Service.impl;

import cn.wolfcode.luowowo.article.domain.StrategyCatalog;
import cn.wolfcode.luowowo.article.mapper.StrategyCatalogMapper;
import cn.wolfcode.luowowo.article.query.StrategyCatalogQuery;
import cn.wolfcode.luowowo.article.service.IStrategyCatalogService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class StrategyCatalogServiceImpl implements IStrategyCatalogService{
    @Autowired
    private StrategyCatalogMapper strategyCatalogMapper;


    public PageInfo query(StrategyCatalogQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<StrategyCatalog> list = strategyCatalogMapper.selectForList(qo);
        return new PageInfo(list);
    }

    public void saveOrUpdate(StrategyCatalog strategyCatalog) {
        if(strategyCatalog.getId() == null){
            strategyCatalogMapper.insert(strategyCatalog);
        }else{
            strategyCatalogMapper.updateByPrimaryKey(strategyCatalog);
        }
    }

    public void delete(Long id) {
        strategyCatalogMapper.deleteByPrimaryKey(id);
    }

    public List<StrategyCatalog> getCatalogByStrategyId(Long id) {
        return strategyCatalogMapper.getCatalogByStrategyId(id);

    }

    public List<StrategyCatalog> selectCatalogByDestId(Long id) {

        return strategyCatalogMapper.selectCatalogByDestId(id);
    }

    public StrategyCatalog get(Long catalogId) {
        return strategyCatalogMapper.selectByPrimaryKey(catalogId);

    }

}
